package com.example.administrator.maizuofilm.cinemaschedule.adapter;

import java.util.List;

import com.example.administrator.maizuofilm.R;
import com.lidroid.xutils.BitmapUtils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class GalleyAdapter extends BaseAdapter {
     private  List<String>   imgUrl;
     private  LayoutInflater  layout;
     private  BitmapUtils  bitmapUtils;
	
	public  GalleyAdapter(Context context,List<String> imgUrl){
		  this.imgUrl=imgUrl;
		  layout=LayoutInflater.from(context);
		  bitmapUtils=new BitmapUtils(context);
	}
	@Override
	public int getCount() {
		return imgUrl.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return imgUrl.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		 ImageView img=null;
		if(convertView==null){
			 convertView=layout.inflate(R.layout.item_cinema_schedule, null);
			  img=(ImageView) convertView.findViewById(R.id.cinema_sche_cover);
			  convertView.setTag(img);
		 }else{
			 img=(ImageView) convertView.getTag();
		 }
		bitmapUtils.display(img, imgUrl.get(position));
		return convertView;
	}

}
